home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
www
/
amitrix
/
httx17.lha
/
HTTX
/
HTTXPluginPRT.awebrx
< prev
next >
Wrap
Text File
|
1998-03-07
|
4KB
|
243 lines
/*
Print current document as TEXT using HTTX
$VER: HTTXPluginPRT 2.1 (23.1.98) by Gabriele Favrin (favrin@tin.it)
*/
options results
options Failat 999
parse ARG mode mode_data .
parse SOURCE . . . resolved .
plugin_path = FindPath(resolved)
'GetCFG TEMPPATH VAR' prefs_temppath
If Right(prefs_temppath, 1) ~= "/" & Right(prefs_temppath, 1) ~= ":" then do
prefs_temppath=prefs_temppath"/"
End
req_title = '"Print as text"'
temp_out = prefs_temppath"temp_HTTXP_Output.txt"
temp_name = prefs_temppath"temp_HTTXP_file"
temp_inc = prefs_temppath"temp_HTTXP_header"
del_list = prefs_temppath"temp_HTTXP_#?"
eol = '0A'x
trg = ""
force = ""
string = ""
option = ""
append = ""
converted = 0
prefs_info = 0
prefs_report = 1
prefs_save_noheader=0
prefs_print_noheader=0
Call ReadCfg()
If (mode == "TARGET") then do
trg="TARGET" mode_data
End
'Get URL VAR' doc_url trg
'Get TITLE VAR' doc_title trg
'GetCFG FRAMES'
If result == 0 then do
frms.0=0
End
else do
'Get FRAMES ALL' trg 'STEM' frms
End
If (frms.0 = 0) then do
Call SaveHTML()
Call Convert()
Call CleanUp()
End
else do
prefs_report=0
'Request' req_title '"Selected document contains frames." "Convert _All|_Select frame(s)|_Cancel"'
If rc == 5 then exit 0
option=result
do ct=0 for (frms.0)+1
If ct > 0 then do
doc_url=frms.ct.url
doc_title=frms.ct.name
trg="TARGET="frms.ct.id
End
If option == 1 then do
'Get FRAMESET' trg
If (result == 0) then do
If converted then do
drop append
string=eol||"----"||eol
End
Call SaveHTML()
Call Convert()
Call CleanUp()
End
End
else do
'Open "'doc_url'"'
'Wait "'doc_url'"'
'Get FRAMESET'
If (result == 0) then do
'Request' req_title '"Convert this frame?" "_Yes|_No|_Cancel"'
If (rc == 5) then do
Call CleanUp()
If (ct > 0) then do
'GO' ct 'BACK'
End
exit 0
End
If result == 1 then do
trg=""
string=""
Call SaveHTML()
Call Convert()
Call CleanUp()
End
End
End
End
If option == 1 then do
Call displayOutput()
Call CleanUp()
End
else do
If (option == 2) & (ct > 0) then do
'GO' ct 'BACK'
End
Call CleanUp()
End
End
exit 0
CleanUp:
/*address command 'C:Delete >NIL: QUIET' del_list*/
return
SaveHTML:
'SaveAs "'temp_name'" NOICON' trg
If (rc ~= 0) then do
'Request 'req_title' "Error while saving HTML on temporary path*N *N'prefs_temppath'" "_Ok" NOWAIT'
exit 0
End
return
Convert:
'Get MIME VAR' mtype trg
If (Upper(mtype) == "TEXT/HTML") then do
drop force
End
else do
force=""
End
Call PrepareFile()
res=httx()
If (res == 212) then do
'Request 'req_title' "File is not HTML! Print anyway?" "_Print|_Cancel"'
If (rc ~= 5) then do
address command 'C:Copy "'temp_name'" "PRT:"'
prefs_report=0
res=0
Call displayOutput()
End
End
else do
If option == "" then do
Call displayOutput()
End
End
converted=1
return
httx:
address command '"'plugin_path'HTTX" >'temp_out' "'temp_name'" PRINT NOHEADER CFG=HTTXprt.prefs INCLUDE="'temp_inc'"' force append
return rc
DisplayOutput:
If (prefs_report == 1) then do
'Open "file:///'temp_out'" RELOAD'
'Wait "file:///'temp_out'"'
End
else do
If (res == 0) then do
'Request 'req_title' "File printed" "_Ok" NOWAIT'
End
else do
'Request 'req_title' "Error 'rc'" "_Ok" NOWAIT'
End
End
return
PrepareFile:
If Open(fp, temp_inc, 'W') then do
If (prefs_save_noheader == 0) then do
If (prefs_info == 1) then do
'Get INFO STEM' infos trg
If (infos.0 > 0) then do
string=string||eol||"Header:"||eol
do ctx=1 for infos.0
If (infos.ctx.type ~= "CACHE") then do
string=string||infos.ctx.value||eol
If infos.ctx.type == "LINK" then string=string||eol||infos.ctx.url
End
End
End
End
string=string||eol||'URL : 'doc_url||eol'Title: 'doc_title
End
WriteCH(fp, string)
Call Close(fp)
End
return
ReadCfg:
If Open(rcfg_fp, 'ENV:HTTXPlugin.config', 'R') then do
cfg=ReadLN(rcfg_fp)
If Left(cfg, 6) == "prefs_" then do
interpret translate(strip(cfg), ';',' ')
prefs_savedir=Translate(prefs_savedir, ' ', ';')
End
Call Close(rcfg_fp)
End
FindPath:
procedure
parse ARG pathf
dir_pos=Max(lastpos('/', pathf), lastpos(':', pathf))
If dir_pos > 0 then do
return(left(pathf,dir_pos))
End
else do
return('')
End